<?php
namespace Components\Account\User\Order\Products;

class Service {
	public function find($parameters = []) {
		$model = Model::find($parameters);
		if(!$model -> valid()) {
			return ['code' => -1, 'message' => '数据不存在或已删除'];
		}

		return ['code' => 0, 'user_order_products'=>$model];
	}

	public function create($data) {
		$model = new Model($data);
		if(!$model -> create()) {
			$messages = $model -> getMessages();
			return ['code' => -1, 'message' => $messages[0] -> getMessage()];
		}

		return ['code' => 0, 'user_order_products'=>$model];
	}
}
